package org.jiuling.aliyun.sms.convert;

import org.jiuling.aliyun.config.exception.AliYunConfigRuntimeException;
import org.jiuling.aliyun.sms.enums.TemplateTypeEnum;
import org.jiuling.aliyun.sms.model.QuerySmsTemplateResponseModel;
import org.jiuling.aliyun.sms.model.enums.AuditStatusEnum;
import org.jiuling.basics.converter.DateConvert;
import org.jiuling.basics.enums.DateTimeFormatEnum;
import org.jiuling.basics.exception.BasicsException;
import org.jiuling.basics.util.EnumUtil;

/**
 * 查询短信模板请求转换
 * @author 紫灵
 * @date 2023年02月13日 22时42分54秒
 */
public class QuerySmsTemplateResponseConvert {

    /** 私有构造方法，禁止创建对象 */
    private QuerySmsTemplateResponseConvert(){}

    /**
     * 内容转模型
     * @param querySmsTemplateResponseBody 查询短信模板请求内容
     * @return 查询短信模板请求模型
     */
    public static QuerySmsTemplateResponseModel bodyToModel(com.aliyun.dysmsapi20170525.models.QuerySmsTemplateResponseBody querySmsTemplateResponseBody){
        QuerySmsTemplateResponseModel querySmsTemplateResponseModel = new QuerySmsTemplateResponseModel();
        querySmsTemplateResponseModel.setTemplateContent(querySmsTemplateResponseBody.getTemplateContent());
        querySmsTemplateResponseModel.setTemplateCode(querySmsTemplateResponseBody.getTemplateCode());
        querySmsTemplateResponseModel.setTemplateName(querySmsTemplateResponseBody.getTemplateName());
        querySmsTemplateResponseModel.setReason(querySmsTemplateResponseBody.getReason());
        querySmsTemplateResponseModel.setCode(querySmsTemplateResponseBody.getCode());
        querySmsTemplateResponseModel.setMessage(querySmsTemplateResponseBody.getMessage());
        querySmsTemplateResponseModel.setRequestId(querySmsTemplateResponseBody.getRequestId());
        try {
            querySmsTemplateResponseModel.setTemplateStatus(EnumUtil.valueOfEnum(AuditStatusEnum.class,querySmsTemplateResponseBody.getTemplateStatus(),"getCode"));
            querySmsTemplateResponseModel.setTemplateType(EnumUtil.valueOfEnum(TemplateTypeEnum.class,querySmsTemplateResponseBody.getTemplateType(),"getValue"));
            querySmsTemplateResponseModel.setCreateDate(DateConvert.stringToDate(querySmsTemplateResponseBody.getCreateDate(), DateTimeFormatEnum.yyyy_MM_dd_HH_mm_ss));
        }catch (BasicsException e) {
            throw new AliYunConfigRuntimeException(e.getLocalizedMessage());
        }
        return querySmsTemplateResponseModel;
    }

    /**
     * 内容转模型
     * @param querySmsTemplateResponseBody 查询短信模板请求内容
     * @return 查询短信模板请求模型
     */
    public static QuerySmsTemplateResponseModel bodyToModel(com.aliyun.sdk.service.dysmsapi20170525.models.QuerySmsTemplateResponseBody querySmsTemplateResponseBody){
        QuerySmsTemplateResponseModel querySmsTemplateResponseModel = new QuerySmsTemplateResponseModel();
        querySmsTemplateResponseModel.setTemplateContent(querySmsTemplateResponseBody.getTemplateContent());
        querySmsTemplateResponseModel.setTemplateCode(querySmsTemplateResponseBody.getTemplateCode());
        querySmsTemplateResponseModel.setTemplateName(querySmsTemplateResponseBody.getTemplateName());
        querySmsTemplateResponseModel.setReason(querySmsTemplateResponseBody.getReason());
        querySmsTemplateResponseModel.setCode(querySmsTemplateResponseBody.getCode());
        querySmsTemplateResponseModel.setMessage(querySmsTemplateResponseBody.getMessage());
        querySmsTemplateResponseModel.setRequestId(querySmsTemplateResponseBody.getRequestId());
        try {
            querySmsTemplateResponseModel.setTemplateStatus(EnumUtil.valueOfEnum(AuditStatusEnum.class,querySmsTemplateResponseBody.getTemplateStatus(),"getCode"));
            querySmsTemplateResponseModel.setTemplateType(EnumUtil.valueOfEnum(TemplateTypeEnum.class,querySmsTemplateResponseBody.getTemplateType(),"getValue"));
            querySmsTemplateResponseModel.setCreateDate(DateConvert.stringToDate(querySmsTemplateResponseBody.getCreateDate(), DateTimeFormatEnum.yyyy_MM_dd_HH_mm_ss));
        }catch (BasicsException e) {
            throw new AliYunConfigRuntimeException(e.getLocalizedMessage());
        }
        return querySmsTemplateResponseModel;
    }

}
